package com.example.farmeri.pojo;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 农田实体
 */
public class Farm implements Parcelable {

    private Integer id;
    private String name;

    private String location;

    private String size;

    private Date createDate;

    private String createId;

    private Date updateDate;

    private String updateId;

    private String remarks;
    private String temperature;//标准温度
    private String humidity;//标准湿度
    private String illumination;//标准光照

    private Boolean delFlag;

    private String userId;

    private User user;

    private List<FarmArea> areaList = new ArrayList<>();

    protected Farm(Parcel in) {
        if (in.readByte() == 0) {
            id = null;
        } else {
            id = in.readInt();
        }
        name = in.readString();
        location = in.readString();
        size = in.readString();
        createId = in.readString();
        updateId = in.readString();
        remarks = in.readString();
        temperature = in.readString();
        humidity = in.readString();
        illumination = in.readString();
        byte tmpDelFlag = in.readByte();
        delFlag = tmpDelFlag == 0 ? null : tmpDelFlag == 1;
        userId = in.readString();
    }

    public static final Creator<Farm> CREATOR = new Creator<Farm>() {
        @Override
        public Farm createFromParcel(Parcel in) {
            return new Farm(in);
        }

        @Override
        public Farm[] newArray(int size) {
            return new Farm[size];
        }
    };

    public List<FarmArea> getAreaList() {
        return areaList;
    }

    public void setAreaList(List<FarmArea> areaList) {
        this.areaList = areaList;
    }

    public String getTemperature() {
        return temperature;
    }

    public void setTemperature(String temperature) {
        this.temperature = temperature;
    }

    public String getHumidity() {
        return humidity;
    }

    public void setHumidity(String humidity) {
        this.humidity = humidity;
    }

    public String getIllumination() {
        return illumination;
    }

    public void setIllumination(String illumination) {
        this.illumination = illumination;
    }


    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getCreateId() {
        return createId;
    }

    public void setCreateId(String createId) {
        this.createId = createId;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getUpdateId() {
        return updateId;
    }


    public void setUpdateId(String updateId) {
        this.updateId = updateId;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public Boolean getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Boolean delFlag) {
        this.delFlag = delFlag;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (id == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(id);
        }
        dest.writeString(name);
        dest.writeString(location);
        dest.writeString(size);
        dest.writeString(createId);
        dest.writeString(updateId);
        dest.writeString(remarks);
        dest.writeString(temperature);
        dest.writeString(humidity);
        dest.writeString(illumination);
        dest.writeByte((byte) (delFlag == null ? 0 : delFlag ? 1 : 2));
        dest.writeString(userId);
    }
}
